import request from "@/utils/request";
import store from "@/store/index";
export default {
  getList(params, currentPage, pageSize) {
    const { title, time } = params;
    let startTime = null;
    let endTime = null;
    if (time) {
      startTime = time[0];
      endTime = time[1];
    }
    const data = {
      currentPage,
      pageSize,
      params: {
        startTime,
        endTime,
        title,
        role: store.getters.roles[0],
      },
    };

    return request({
      url: `/testResult/getList`,
      method: "post",
      data,
    });
  },
  getTotal(params) {
    const { title, time } = params;
    let startTime = null;
    let endTime = null;
    if (time) {
      startTime = time[0];
      endTime = time[1];
    }
    const data = {
      startTime,
      endTime,
      title,
      role: store.getters.roles[0],
    };
    return request({
      url: `/testResult/getTotal`,
      method: "post",
      data,
    });
  },

  allAnalysis() {
    return request({
      url: "/testResult/analysis/all",
      method: "get",
    });
  },

  analysisBySubject(subjectId) {
    return request({
      url: `/testResult/analysis/${subjectId}`,
      method: "get",
    });
  },

  anglysisNumber() {
    return request({
      url: "/testResult/analysis/numbers",
      method: "get",
    });
  },

  getById(id) {
    return request({
      url: `/testResult/getById/${id}`,
      method: "get",
    });
  },
};
